<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">IMEI号统计</ui:define>
    <ui:define name="content">
        <h:form id="imei-stat">
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton value="导出表内数据" icon="fa fa-download"
                                         oncomplete="PF('exportDialog').show()"/>
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{imeiStatListBean.onReset()}" icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                        <p:commandButton value="新增导入" icon="fa fa-upload"
                                        oncomplete="PF('importDialog').show()"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="时间"/>
                        </div>
                        <div class="ui-g-3">
                            <p:calendar
                                    id="createStartTime" styleClass="autoWidthCalendar"
                                    value="#{imeiStatListBean.$.createStartTime}"
                                    locale="#{constants:get('LOCALE')}"
                                    timeZone="#{constants:get('TIME_ZONE')}"
                                    pattern="#{constants:get('DATE_FORMAT')}"/>
                            <span>—</span>
                            <p:calendar
                                    id="createEndTime" styleClass="autoWidthCalendar"
                                    value="#{imeiStatListBean.$.createEndTime}"
                                    locale="#{constants:get('LOCALE')}"
                                    timeZone="#{constants:get('TIME_ZONE')}"
                                    pattern="#{constants:get('DATE_FORMAT')}"/>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="产品编号"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectCheckboxMenu id="productIds" value="#{imeiStatListBean.$.productIdList}"
                                                  updateLabel="true" multiple="true" filter="true"
                                                  filterMatchMode="contains">
                                <f:selectItems
                                        value="#{imeiStatListBean.commProductIds}"
                                        var="product"
                                        itemLabel="#{product.name}(#{product.productId})" itemValue="#{product.productId}"/>
                            </p:selectCheckboxMenu>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="渠道编号"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectCheckboxMenu id="channels" value="#{imeiStatListBean.$.channelIdList}"
                                                  updateLabel="true" multiple="true" filter="true"
                                                  filterMatchMode="contains">
                                <f:selectItems
                                        value="#{imeiStatListBean.commProductChannels}"
                                        var="channel"
                                        itemLabel="#{channel.channelName}(#{channel.channelCode})" itemValue="#{channel.channelCode}"/>
                            </p:selectCheckboxMenu>
                        </div>
                    </div>
                    <div class="ui-g-12 card">
                        <p:dataTable id="statisticRecordDataTable"
                                     style="width: 100%;text-align:center"
                                     var="record"
                                     value="#{imeiStatListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">

                            <p:column headerText="操作">
                                <p:commandButton icon="fa fa-fw fa-remove" value="删除"
                                               actionListener="#{imeiStatListBean.onDelete(record.id)}"
                                               process="@this" update="@form">
                                    <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                </p:commandButton>
                            </p:column>
                            
                            <p:column headerText="日期"  style="text-align:center;width: 150px">
                                <h:outputText value="#{record.createDate}">
                                    <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="产品" style="text-align:center;">
                                <h:outputText value="#{record.productName}"/>
                            </p:column>
                            <p:column headerText="渠道" style="text-align:center;">
                                <h:outputText value="#{record.channelName}"/>
                            </p:column>
                            <p:column headerText="注册人数" style="text-align:center;">
                                <h:outputText value="#{record.registerCount}"/>
                            </p:column>
                            <p:column headerText="登录人数" style="text-align:center;">
                                <h:outputText value="#{record.loginCount}"/>
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </div>
            <ui:include src="imei-stat-export-dialog.xhtml"/>
            <ui:include src="imei-stat-import-dialog.xhtml"/>
        </h:form>
    </ui:define>
</ui:composition>